﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Xml.Linq;

namespace vmlModel.Entities
{
   public  class vmlStroke : vmlObject
    {
       public Color Color { get { return (vmlObjElement.Attribute("color") != null) ? vmlUtils.StringToColor(vmlObjElement.Attribute("color").Value.Split(char.Parse(" "))[0]) : Colors.Transparent; } }
       public Color Color2 { get { return (vmlObjElement.Attribute("color2") != null) ? vmlUtils.StringToColor(vmlObjElement.Attribute("color2").Value.Split(char.Parse(" "))[0]) : Colors.Transparent; } }
       public DoubleCollection vmlDashStyle { get { return (vmlObjElement.Attribute("dashstyle") != null) ? vmlUtils.DashStyleFromVML(vmlObjElement.Attribute("dashstyle").Value) : DashStyles.Solid.Dashes; } }
       public PenLineJoin vmlJoinStyle { 
           get { 
               
               if (vmlObjElement.Attribute("joinstyle") != null)
               {
                   switch (vmlObjElement.Attribute("joinstyle").Value)
                   {
                       case "bevel":
                           return PenLineJoin.Bevel;
                       case "miter":
                           return PenLineJoin.Miter; 
                       case "round":
                           return PenLineJoin.Round; 
                       default:
                           break;
                   }
                   
               }
               return PenLineJoin.Round; 
           } 
       }
       //single 
       // "thinthin", create a rectangle with the outline (1:1:1)
       //"thinthick", create a rectangle with the outline (1:1:2)
       //"thickthin", create a rectangle with the outline (2:1:1)
       //"thickbetweenthin",create a rectangle with the outline (1:1:2:1:1)
       public string LineStyle { get { return (vmlObjElement.Attribute("linestyle") != null) ? vmlObjElement.Attribute("linestyle").Value : "single"; } }
       public double Opacity { get { return (vmlObjElement.Attribute("opacity") != null) ? double.Parse(vmlObjElement.Attribute("opacity").Value) : 1; } }
       public double Weight
       {
           get
           {
               if (vmlObjElement.Attribute("weight") != null)
               {
                   string atrrValue = vmlObjElement.Attribute("weight").Value;
                   return vmlUtils.GetLength(atrrValue);
               }
               return 1;
           }
       }
       public vmlStroke()
       {

       }
       public vmlStroke(XElement _vmlObjElement)
           : base(_vmlObjElement)
       {
           FillMe();
       }

       private void FillMe()
       {
           
       }

    }
}
